package com.techfort.metalrss.core;

import android.database.Cursor;
import android.os.Parcel;
import android.os.Parcelable;

public class Feed implements Parcelable {
	
	/*
	 *  fields names are ugly but i didn't want to write a custom
	 *  deserializer from json to java so i had to keep database column names
	 */
	
	
	private int id;
	private String feed_name;
	private String link;
	private int lang_id;
	
	public Feed(){}

	public Feed(int id, String feedName, String link, int langId) {
		super();
		this.id = id;
		feed_name = feedName;
		this.link = link;
		lang_id = langId;
	}
	
	public Feed(Parcel in){
		id = in.readInt();
		feed_name = in.readString();
		link = in.readString();
		lang_id = in.readInt();		
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getFeed_name() {
		return feed_name;
	}

	public void setFeed_name(String feedName) {
		feed_name = feedName;
	}

	public String getLink() {
		return link;
	}

	public void setLink(String link) {
		this.link = link;
	}

	public int getLang_id() {
		return lang_id;
	}

	public void setLang_id(int langId) {
		lang_id = langId;
	}

	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		
		dest.writeInt(id);
		dest.writeString(feed_name);
		dest.writeString(link);
		dest.writeInt(lang_id);
	}
	
	
	public static final Parcelable.Creator<Feed> CREATOR = new Parcelable.Creator<Feed>() {
	      public Feed createFromParcel(Parcel source) {
	            return new Feed(source);
	      }
	      public Feed[] newArray(int size) {
	            return new Feed[size];
	      }
	};
	
	public  static Feed readFromCursor(Cursor cur){
		return new Feed(cur.getInt(0), cur.getString(1), cur.getString(3),cur.getInt(2));
	}
	
	
}
